package com.ruoyi.project.module.zhuti.controller;

import java.util.List;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.project.module.jingdian.domain.Jingdian;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.module.zhuti.domain.Zhuti;
import com.ruoyi.project.module.zhuti.service.IZhutiService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.domain.AjaxResult;

/**
 * 主题游 信息操作处理
 * 
 * @author ruoyi
 * @date 2018-11-13
 */
@Controller
@RequestMapping("/module/zhuti")
public class ZhutiController extends BaseController
{
    private String prefix = "module/zhuti";
	
	@Autowired
	private IZhutiService zhutiService;
	
	@RequiresPermissions("module:zhuti:view")
	@GetMapping()
	public String zhuti()
	{
	    return prefix + "/zhuti";
	}
	
	/**
	 * 查询主题游列表
	 */
	@RequiresPermissions("module:zhuti:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(Zhuti zhuti)
	{
		startPage();
        List<Zhuti> list = zhutiService.selectZhutiList(zhuti);
		return getDataTable(list);
	}
	/**
	 * 导出主题类型
	 */

	@Log(title = "主题", businessType = BusinessType.EXPORT)
	@RequiresPermissions("system:zhuti:export")
	@PostMapping("/export")
	@ResponseBody
	public AjaxResult export(Zhuti zhuti) throws Exception
	{
		try
		{
			List<Zhuti> list = zhutiService.selectZhutiList(zhuti);
			ExcelUtil<Zhuti> util = new ExcelUtil<Zhuti>(Zhuti.class);
			return util.exportExcel(list, "zhuti");
		}
		catch (Exception e)
		{
			return error("导出Excel失败，请联系网站管理员！");
		}
	}
	/**
	 * 新增主题游
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存主题游
	 */
	@RequiresPermissions("module:zhuti:add")
	@Log(title = "主题游", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(Zhuti zhuti)
	{		
		return toAjax(zhutiService.insertZhuti(zhuti));
	}

	/**
	 * 修改主题游
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		Zhuti zhuti = zhutiService.selectZhutiById(id);
		mmap.put("zhuti", zhuti);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存主题游
	 */
	@RequiresPermissions("module:zhuti:edit")
	@Log(title = "主题游", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(Zhuti zhuti)
	{		
		return toAjax(zhutiService.updateZhuti(zhuti));
	}
	
	/**
	 * 删除主题游
	 */
	@RequiresPermissions("module:zhuti:remove")
	@Log(title = "主题游", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(zhutiService.deleteZhutiByIds(ids));
	}
	
}
